package com.study;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author Ychiha
 * @version 1.0
 * @date 4/1/2022 下午10:23
 */
@SpringBootApplication
@Controller
public class App {

    public static void main(String [] args){
        SpringApplication.run(App.class,args);
    }

    @GetMapping("/")
    public ResponseEntity<String> index(){
        try {
            if(MyFilter.auth.get()==0){
                return ResponseEntity.ok("没权限");
            }else{
                return ResponseEntity.ok("有权限");
            }
        }finally {
            //清除缓存 避免内存泄漏和造成上个用户授权而下个用户得到权力
            MyFilter.auth.remove();
        }
    }

}
